﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ArrawManagement : MonoBehaviour
{
    static ArrawManagement instance;
    public GameObject arraw;
    public Transform[] arrawsTrans;

    private bool isArrawExist = false;
    // Start is called before the first frame update
    void Start()
    {
        //单例模式
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;
    }

    // Update is called once per frame
    void Update()
    {
        arrawSwitch();
    }

    /// <summary>
    /// 判断并切换arraw的位置到arrawTrans[i]上
    /// </summary>
    void arrawSwitch()
    {
        if (ScrollRectManager.index == 10)
        {
            arraw.transform.SetParent(transform.GetChild(0));
            arraw.transform.position = new Vector3(arrawsTrans[0].position.x, arrawsTrans[0].position.y, arrawsTrans[0].position.z);
        }
        if (ScrollRectManager.index == 9)
        {
            arraw.transform.SetParent(transform.GetChild(1));
            arraw.transform.position = new Vector3(arrawsTrans[1].position.x, arrawsTrans[1].position.y, arrawsTrans[1].position.z);
        }
        if (ScrollRectManager.index == 8)
        {
            arraw.transform.SetParent(transform.GetChild(2));
            arraw.transform.position = new Vector3(arrawsTrans[2].position.x, arrawsTrans[2].position.y, arrawsTrans[2].position.z);
        }
        if (ScrollRectManager.index == 7)
        {
            arraw.transform.SetParent(transform.GetChild(3));
            arraw.transform.position = new Vector3(arrawsTrans[3].position.x, arrawsTrans[3].position.y, arrawsTrans[3].position.z);
        }
        if (ScrollRectManager.index == 6)
        {
            arraw.transform.SetParent(transform.GetChild(4));
            arraw.transform.position = new Vector3(arrawsTrans[4].position.x, arrawsTrans[4].position.y, arrawsTrans[4].position.z);
        }
        if (ScrollRectManager.index == 5)
        {
            arraw.transform.SetParent(transform.GetChild(5));
            arraw.transform.position = new Vector3(arrawsTrans[5].position.x, arrawsTrans[5].position.y, arrawsTrans[5].position.z);
        }
        if (ScrollRectManager.index == 4)
        {
            arraw.transform.SetParent(transform.GetChild(6));
            arraw.transform.position = new Vector3(arrawsTrans[6].position.x, arrawsTrans[6].position.y, arrawsTrans[6].position.z);
        }
        if (ScrollRectManager.index == 3)
        {
            arraw.transform.SetParent(transform.GetChild(7));
            arraw.transform.position = new Vector3(arrawsTrans[7].position.x, arrawsTrans[7].position.y, arrawsTrans[7].position.z);
        }
        if (ScrollRectManager.index == 2)
        {
            arraw.transform.SetParent(transform.GetChild(8));
            arraw.transform.position = new Vector3(arrawsTrans[8].position.x, arrawsTrans[8].position.y, arrawsTrans[8].position.z);
        }
        if (ScrollRectManager.index == 1)
        {
            arraw.transform.SetParent(transform.GetChild(9));
            arraw.transform.position = new Vector3(arrawsTrans[9].position.x, arrawsTrans[9].position.y, arrawsTrans[9].position.z);
        }
        if (ScrollRectManager.index == 0)
        {
            arraw.transform.SetParent(transform.GetChild(10));
            arraw.transform.position = new Vector3(arrawsTrans[10].position.x, arrawsTrans[10].position.y, arrawsTrans[10].position.z);
        }

    }
}
